import 'package:bxultimate/data/request/home_request.dart';
import 'package:bxultimate/domain/common/app_single_option.dart';
import 'package:bxultimate/domain/home/eps_category.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'state.dart';

class ArticleMoreTabListController extends GetxController
    with GetSingleTickerProviderStateMixin {
  final ArticleMoreTabListState state = ArticleMoreTabListState();

  TabController? tabController;

  @override
  Future<void> onInit() async {
    // TODO: implement onInit
    super.onInit();

    List<EpsCategory> tabs = await HomeRequest.getEpsCategory();
    for(var item in tabs){
      state.tabs.add(AppSingleOption(label: item.name, value: item.id));
    }

    tabController = TabController(length: state.tabs.length, vsync: this);
    tabController?.addListener(() {
      state.currentIndex = tabController?.index;
    });
    state.firstInit = false;
  }
}
